﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GPSStock.aspx.cs" Inherits="GPSTrackingWebsiteManager.Manager.Pages.GPSStock" %>

<!DOCTYPE html>

<link href="../../Css/GPSTrackingWebsite.css" rel="stylesheet" />
<link href="../../Css/messi.css" rel="stylesheet" />
<script src="../../Javascript/jquery-1.11.1.min.js"></script>
<script src="../../Javascript/messi.js"></script>
<script src="../../Javascript/Custom.js"></script>
<script src="../../Javascript/WindowMessageManager.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Dispositivo Manager</title>
    <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
    <script type="text/javascript">
        function resizeGrid() {
            var tableView = $find("<%=GPSGrid.ClientID %>");
            tableView.get_element().style.height = (window.innerHeight) + "px";

            document.getElementById('HiddenFieldHeight').value = (window.innerHeight);
        }

        //Windows Message Manager 
        var objWindowsMessageManager = new WindowsMessageManager();
    </script>
</telerik:RadScriptBlock>    
</head>
<body  onresize="resizeGrid()" style="overflow: hidden">
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>        
       <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="GPSGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="GPSGrid" LoadingPanelID="RadAjaxLoadingPanel1"  />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError"  />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
         <asp:HiddenField ID="HiddenFieldHeight" runat="server" Value="500" />
        <asp:HiddenField ID="HiddenFieldError" runat="server" />        
        <div>
            <telerik:RadGrid ID="GPSGrid" runat="server" AllowSorting="true" AutoGenerateColumns="false" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" OnDeleteCommand="GPSGrid_DeleteCommand" OnInsertCommand="GPSGrid_InsertCommand" OnNeedDataSource="GPSGrid_NeedDataSource" OnUpdateCommand="GPSGrid_UpdateCommand" OnItemDataBound="GPSGrid_ItemDataBound">
                <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                    <CommandItemTemplate>
                        <div style="padding: 5px 5px;"> Menu: 
                             <asp:LinkButton ID="lbAdd" runat="server" CommandName="InitInsert" Visible='<%# !GPSGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/text-plus-icon.png"/>Nuevo dispositivo</asp:LinkButton>
                             <asp:LinkButton ID="lbClearFilters" runat="server" OnClick="lbClearFilters_Click"  Visible='<%# !GPSGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                            <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error técnivo</asp:LinkButton>   
                        </div>                        
                    </CommandItemTemplate>
                    <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Nuevo dispositivo" RefreshText="Actualizar"></CommandItemSettings>

                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>

                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>

                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" EditText="Editar" HeaderStyle-Width="25px" />
                        <telerik:GridButtonColumn  ConfirmText="¿Desea eliminar el registro?" Text="Eliminar" ConfirmDialogType="RadWindow" ConfirmDialogHeight="120" ConfirmDialogWidth="270" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" HeaderStyle-Width="25px"/>                                                     
                        <telerik:GridBoundColumn DataField="GpsImei" FilterControlAltText="Filter Imei column" HeaderText="Imei" UniqueName="GpsImei" MaxLength="15"
                            FilterControlWidth="100px" CurrentFilterFunction="EqualTo" ShowFilterIcon="false"  HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Nombre" UniqueName="Name" MaxLength="50"
                            FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="120px" AutoPostBackOnFilter="true">
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridMaskedColumn DataField="SimNumber" FilterControlAltText="Filter SimNumber column" HeaderText="Nº Sim" UniqueName="SimNumber" MaxLength="8"
                            FilterControlWidth="100px" CurrentFilterFunction="EqualTo" ShowFilterIcon="false" Mask="###############" HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridMaskedColumn>
                        <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter Description column" HeaderText="Descripción" UniqueName="Description" MaxLength="100"
                            FilterControlWidth="150px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="170px" AutoPostBackOnFilter="true">
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ForeColor="Red" ErrorMessage="* Requerido" SetFocusOnError="true"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>
                        <telerik:GridDropDownColumn DataField="GpsTypeId" DataSourceID="sdsGPSType" FilterControlAltText="Filter GPSTypeID column" HeaderText="Tipo" ListTextField="Name" ListValueField="GPSTypeID" UniqueName="GpsTypeId">
                            <FilterTemplate>
                                <telerik:RadComboBox ID="cmbGpsType" DataSourceID="sdsGPSType" DataTextField="Name" DataValueField="GPSTypeID"  Width="100px"
                                    AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("GpsTypeId").CurrentFilterValue %>'
                                    runat="server" OnClientSelectedIndexChanged="GpsTypeIdIndexChanged" Sort="Ascending">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="Todos" Value="" />
                                    </Items>
                                </telerik:RadComboBox>
                                <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                                    <script type="text/javascript">
                                        function GpsTypeIdIndexChanged(sender, args) {
                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                    tableView.filter("GpsTypeId", args.get_item().get_value(), "EqualTo");
                                }
                                    </script>
                                </telerik:RadScriptBlock>
                            </FilterTemplate>
                        </telerik:GridDropDownColumn>
                        <telerik:GridDropDownColumn DataField="GpsModelId" DataSourceID="sdsGPSModels" FilterControlAltText="Filter GPSModelID column" HeaderText="Modelo" ListTextField="Name" ListValueField="GPSModelID" UniqueName="GpsModelId">
                              <FilterTemplate>
                                <telerik:RadComboBox ID="cmbGPSModel" DataSourceID="sdsGPSModels" DataTextField="Name" DataValueField="GPSModelID"  Width="100px"
                                    AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("GPSModelID").CurrentFilterValue %>'
                                    runat="server" OnClientSelectedIndexChanged="GPSModelIDIndexChanged" Sort="Ascending">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="Todos" Value=""/>
                                    </Items>
                                </telerik:RadComboBox>
                                <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
                                    <script type="text/javascript">
                                        function GPSModelIDIndexChanged(sender, args) {
                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                            tableView.filter("GPSModelID", args.get_item().get_value(), "EqualTo");
                                        }
                                    </script>
                                </telerik:RadScriptBlock>
                                  </FilterTemplate>
                        </telerik:GridDropDownColumn>
                        <telerik:GridBoundColumn DataField="Status" FilterControlAltText="Filter Description column" HeaderText="Estado" UniqueName="Status" MaxLength="100" ReadOnly="true" ForceExtractValue="Always"
                            FilterControlWidth="80px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="100px" AutoPostBackOnFilter="true">
                        </telerik:GridBoundColumn>
                    </Columns>

                    <EditFormSettings>
                        <EditColumn InsertText="Agregar" UpdateText="Actualizar" CancelText="Cancelar" ButtonType="ImageButton"></EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <ClientSettings EnableRowHoverStyle="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                     <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>
        </div>
        <asp:SqlDataSource ID="sdsGPSType" SelectCommandType="StoredProcedure" SelectCommand="GPSType_Get_List" runat="server"></asp:SqlDataSource>
        <asp:SqlDataSource ID="sdsGPSModels" SelectCommandType="StoredProcedure" SelectCommand="GPSModels_Get_List"  runat="server" ></asp:SqlDataSource>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
    </form>
</body>
</html>
